/*
000 - Move forward
001 - Moving off the line to the right
010 - Not used
011 - Slightly off the line to the right
100 - Moving off the line to the left
101 - Centered over the line
110 - Slightly off the line to the left
111 - No line - Overshoot
*/

#include "motors.ic"

//Sensors digital inputs
#define LINEFOLLOW_LEFT (digital())
#define LINEFOLLOW_CENTER (digital())
#define LINEFOLLOW_RIGHT (digital())

//Timeout timers
#define NOLINE_TIMEOUT x
#define INLINE_TIMEOUT x

//Global variables
int lineflag; //Contains a representation of the 3 sensors
int overshoot; //A flag that indicates if we have lost the line at a turn
int lastlineflag //Store the las representation of the 3 sensors

//Functions
int linefollow();
int readlinesensors(); //Function to read the 3 line sensors



int linefollow()
{
    while(1){
        lineflag = readlinesensors();
	switch(lineflag){
	    case 000: //Move forward

		break;
	    case 001: //Moving off the line to the right
	
		break;
	    case 010: //Not used

		break;
	    case 011: //Slightly off the line to the right

		break;
	    case 100: //Moving off the line to the left

		break;
	    case 101: //Not Used (Error)

		break;
	    case 110: //Slightly off the line to the left

		break;
	    case 111: //No line - Overshoot

		break;
	}
	lastlineflag = lastline;
	sleep(0.2);
    }
}

int readlinesensors(){
    return LINEFOLLOW_LEFT*100 + LINEFOLLOW_CENTER*10 + LINEFOLLOW_RIGHT;
}
